/**
 * \file Mutex.cpp
 * \brief Mutex declaration class
 * \author Edouard ROGE
 * \date 01 September 2012
 */

#include "Mutex.h"
namespace Core
{
	namespace Thread
	{
		Mutex::Mutex()
		{
			m_Mutex = CreateMutex(NULL, FALSE, NULL);
		}

		Mutex::~Mutex()
		{
		}

		error Mutex::Lock()
		{
			return (WaitForSingleObject(m_Mutex, INFINITE) == WAIT_OBJECT_0 ? errOK : errFailed);
		}

		error Mutex::Unlock()
		{
			return (ReleaseMutex(m_Mutex) ? errOK : errFailed);

		}
	}
}
